<?php

namespace api\modules\app\controllers;

use api\components\DataCenter;
use api\traits\ControllerTrait;
use app\components\PaidanService;
use Yii;
use api\components\BaseController;
use api\modules\app\models\UnitHistory;
use api\modules\app\services\HistoryService;
use api\modules\app\services\UnitService;
use yii\helpers\Json;

class HistoryController extends BaseController
{

    use ControllerTrait;
    public $modelClass = 'api\\modules\\app\\models\\UnitHistory';

    public function actions()
    {
        $actions = parent::actions();
        unset($actions['create'], $actions['index']);

        return $actions;
    }

    public function actionIndex() {
        $query = $this->getQuery();
        $service = new HistoryService();
        $data = $service->search($query);
        $count =  $service->search($query, true);
        if ($data === false) {
            return ['count' => 0, 'data' => []];
        }
        return ['count' => $count, 'data' => $data];
    }

    public function actionScanLog() {
        $params = $this->getParams();
        $service = new HistoryService();
        return $service->scanLog($params);
    }

    public function actionScanStat() {
        $params = $this->getQuery();
        $service = new HistoryService();
        return $service->scanStat($params);
    }

}


